package com.pmcc.cj.repository;

import com.pmcc.cj.entity.CjTrain;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by tomas on 2020/9/12.
 */
public interface CjTrainRepository extends JpaRepository<CjTrain,String> {
    @Modifying
    @Query(value ="select * from cj_train  order by create_time desc ",  nativeQuery = true)
    List<CjTrain> findAllTrainOrderByCreateTimeDesc();

    @Modifying
    @Query(value ="select a.* from cj_train a,cj_train_detail b where a.id=b.train_id and a.fettle!=2 and b.employee_id=?1 order by create_time desc ",  nativeQuery = true)
    List<CjTrain> queryTrainDetailEmployee(String employeeId);

    Page<CjTrain> findAll(Specification<CjTrain> spec, Pageable var1);
}
